package com.banmoon.algorithm.leetcode;

public class Question2006 {

    public static void main(String[] args) {
        int[] nums = {1, 2, 2, 1};
        System.out.println(countKDifference(nums, 1));
    }

    public static int countKDifference(int[] nums, int k) {
        int length = nums.length;
        int num = 0;
        for (int i = 0; i < length-1; i++) {
            for (int j = i+1; j < length; j++) {
                if(Math.abs(nums[i]-nums[j])==k)
                    ++num;
            }
        }
        return num;
    }

}
